package com.cn.demo.springboot.globalexception.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.cn.demo.springboot.globalexception.service.DefaultViewNameInterfacesImpl;
import com.cn.demo.springboot.globalexception.service.HandlerExceptionResolverImpl;
import com.cn.demo.springboot.globalexception.service.ViewNameInterfaces;
/**
 * 全局异常定义
 * @author admin
 *
 */
@Configuration
@AutoConfigureBefore(WebMvcAutoConfiguration.class)
public class GlobalExceptionConfig {
	private final static Logger log = LoggerFactory.getLogger(GlobalExceptionConfig.class);
	@Bean  
    public HandlerExceptionResolverImpl getHandlerExceptionResolverImpl() {
		log.debug("HandlerExceptionResolver Bean init");
		return new HandlerExceptionResolverImpl();
	}
	
	@Bean
	@ConditionalOnMissingBean(value = ViewNameInterfaces.class,search = SearchStrategy.CURRENT) 
    public DefaultViewNameInterfacesImpl getDefaultViewNameInterfaces() {
		return new DefaultViewNameInterfacesImpl();
	}
}
